<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="lib/layui-v2.5.6/layui/css/layui.css">
    <link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>产品分类</title>
    <style>

        tr {
            margin-bottom: 10px;
        }

        input {
            width: 200px;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 产品管理 <span
        class="c-gray en">&gt;</span> 产品分类 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>

<div class="pos-a"
     style="margin-top:10px;width:200px;left:0;top:0; bottom:0; height:100%; border-right:1px solid #e5e5e5; background-color:#f5f5f5; overflow:auto;">
    <div id="product-category-list"></div>
</div>

<div id="product-right-box" style="float: left;width: 500px;height: 500px;margin: 100px 25%;">
    <div id="product-text-box">
        <form action="" method="post" id="category-update-form">
            <table>
                <tr>
                    <td><label for="categoryId">编号：</label></td>
                    <td><input type="text" name="categoryId" id="categoryId"
                               placeholder="请输入标题"
                               autocomplete="off" class="layui-input" readonly></td>
                </tr>
                <tr>
                    <td><label for="categoryName">分类名称：</label></td>
                    <td><input type="text" name="categoryName" id="categoryName"
                               placeholder="请输入标题"
                               autocomplete="off" class="layui-input"></td>
                </tr>
                <tr>
                    <td><label for="catyDesc">备注：</label></td>
                    <td><textarea name="catyDesc" id="catyDesc" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </td>
                </tr>
            </table>
            <button id="updateCategory" type="button" class="layui-btn layui-btn-normal" style="margin: auto 40%">修改
            </button>
        </form>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="lib/layui-v2.5.6/layui/layui.js"></script>
<script type="text/javascript">
    var layer;
    $(document).ready(function () {
        layui.use(['tree', 'layer'], function () {
            var tree = layui.tree;
            var treeList = initTree();
            layer = layui.layer;
            //渲染
            var inst1 = tree.render({
                elem: '#product-category-list'  //绑定元素
                , id: "categoryTree"
                , data: treeList
                , click: function (obj) {
                    $("#categoryId").val(obj.data.id);
                    $("#categoryName").val(obj.data.title);
                    $("#catyDesc").val(obj.data.catyDesc);
                }
            });

            $("#updateCategory").click(function () {
                var categoryForm = $("#category-update-form").serialize();
                $.ajax({
                    url: "/Olala/category/updateById",
                    data: categoryForm,
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (result) {
                        layer.msg("操作成功，请刷新");
                    }
                });

            });
        });


    });

    function initTree() {
        var treeList;
        $.ajax({
            url: "/Olala/category/brandCateGoryToTree",
            type: "post",
            dataType: "json",
            async: false,
            success: function (result) {
                treeList = result.data;

            }
        });
        return treeList;
    }
</script>
</body>
</html>